import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { RedisModule } from './redis/redis.module';
import { LoginModule } from './client/module/login/login.module';
import { BaseModelModule } from './model/base-model/base-model.module';
import { UserModelModule } from './model/user-model/user-model.module';
import { XjwtModule } from './xjwt/xjwt.module';
import { DeviceModule } from './client/module/device/device.module';
import { DeviceModelModule } from './model/device-model/device-model.module';
import { ChargeStrategyModelModule } from './model/charge-strategy-model/charge-strategy-model.module';
import { PaymentModule } from './payment/payment.module';
import { ChargeModule } from './client/module/charge/charge.module';
import { ChargeOrderModelModule } from './model/charge-order-model/charge-order-model.module';
import { UserWalletModelModule } from './model/user-wallet-model/user-wallet-model.module';
import { UserWalletLogModule } from './model/user-wallet-log/user-wallet-log.module';
import { AddChargeOrderModelModule } from './model/add-charge-order-model/add-charge-order-model.module';
import config from './config';
import white from './config/white'
import { DevicePortModelModule } from './model/device-port-model/device-port-model.module';
import { UserModule } from './client/module/user/user.module';
import { ChargeOrderModule } from './client/module/charge-order/charge-order.module';
import { GatewayModule } from './gateway/gateway.module';
import { MongooseModule } from '@nestjs/mongoose';
import { RechargeModule } from './client/module/recharge/recharge.module';
import { RechargeOrderModelModule } from './model/recharge-order-model/recharge-order-model.module';
import { AppletModelModule } from './model/applet-model/applet-model.module';
import { AppletModule } from './client/module/applet/applet.module';
import { UserWalletModule } from './client/module/user-wallet/user-wallet.module';


@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal : true,
      load : [config, white]
    }),

    TypeOrmModule.forRootAsync({
      inject : [ConfigService],
      useFactory : (configService:ConfigService) => configService.get('database')
    }),
    
    MongooseModule.forRootAsync({
      inject : [ConfigService],
      useFactory : (configService:ConfigService) => configService.get('mongodb')
    }),

    RedisModule,

    LoginModule,
    DeviceModule,
    

    BaseModelModule,
    DeviceModelModule,
    DevicePortModelModule,
    UserModelModule,

    XjwtModule,

    ChargeStrategyModelModule,

    PaymentModule,

    ChargeModule,

    ChargeOrderModelModule,

    UserWalletModelModule,

    UserWalletLogModule,

    AddChargeOrderModelModule,

    UserModule,

    ChargeOrderModule,

    GatewayModule,

    RechargeModule,

    RechargeOrderModelModule,

    AppletModelModule,

    AppletModule,

    UserWalletModule

  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
